package com.hdp.jetpack_mvvm.lifecycle

import android.content.Context
import android.util.Log
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleObserver
import androidx.lifecycle.OnLifecycleEvent

/**
 * 声明周期回调的父类
 */
open class LifecycleObserverBase constructor(
    val context: Context
) :
    LifecycleObserver {
    val TAG = "LifecycleBase"

    @OnLifecycleEvent(Lifecycle.Event.ON_CREATE)
    open fun myOnCreate() {
        Log.e(TAG, "FatherOnCreate")
    }

    @OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
    open fun myOnResume() {
        Log.e(TAG, "FatherOnResume")
    }

    @OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
    fun myOnPause() {
        Log.e(TAG, "FatherOnPause")
    }

    @OnLifecycleEvent(Lifecycle.Event.ON_STOP)
    fun myOnSotp() {
        Log.e(TAG, "FatherOnSotp")
    }

    @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
    fun myOnDestroy() {
        Log.e(TAG, "FatherOnDestroy")
    }
}